#include <iostream>
#include <string>
#include <algorithm>
#include <unordered_map>

using namespace std;

class Solution 
{
public:
    bool canConstruct(string ransomNote, string magazine) 
    {
        unordered_map<char, int> map;
        for(char ch : magazine)
        {
            map[ch]++;
        }
        for(char ch : ransomNote)
        {
            auto it = map.find(ch);
            if(it == map.end() || it->second == 0)
            {
                return false;
            }
            else
            {
                it->second--;
            }
        }
        return true;
    }
};

int main()
{
    Solution sol;

    // 测试用例1
    string ransomNote1 = "a";
    string magazine1 = "b";
    cout << "测试用例1: ransomNote=\"" << ransomNote1 << "\", magazine=\"" << magazine1 << "\"" << endl;
    cout << "结果: " << (sol.canConstruct(ransomNote1, magazine1) ? "true" : "false") << endl;

    // 测试用例2
    string ransomNote2 = "aa";
    string magazine2 = "ab";
    cout << "测试用例2: ransomNote=\"" << ransomNote2 << "\", magazine=\"" << magazine2 << "\"" << endl;
    cout << "结果: " << (sol.canConstruct(ransomNote2, magazine2) ? "true" : "false") << endl;

    // 测试用例3
    string ransomNote3 = "aa";
    string magazine3 = "aab";
    cout << "测试用例3: ransomNote=\"" << ransomNote3 << "\", magazine=\"" << magazine3 << "\"" << endl;
    cout << "结果: " << (sol.canConstruct(ransomNote3, magazine3) ? "true" : "false") << endl;

    // 测试用例4
    string ransomNote4 = "aab";
    string magazine4 = "baa";
    cout << "测试用例4: ransomNote=\"" << ransomNote4 << "\", magazine=\"" << magazine4 << "\"" << endl;
    cout << "结果: " << (sol.canConstruct(ransomNote4, magazine4) ? "true" : "false") << endl;

    // 测试用例5
    string ransomNote5 = "";
    string magazine5 = "abc";
    cout << "测试用例5: ransomNote=\"" << ransomNote5 << "\", magazine=\"" << magazine5 << "\"" << endl;
    cout << "结果: " << (sol.canConstruct(ransomNote5, magazine5) ? "true" : "false") << endl;

    return 0;
}
